/*
 * @Author: Aaron
 * @Date: 2022-04-14 15:29:32
 * @LastEditors: Aaron
 * @LastEditTime: 2022-04-14 16:11:53
 * @Description: file content
 * @FilePath: \ias_ui\src\views\coi\commonJs\createPicDom.js
 * @Company: 沃尔玛
 */
/**
 * 数组生成dom
 * @param {*} list 图片 array<string ||ｏｂｊect>
 * @param {*} key 对象的key
 * @returns dom
 */

import { authentication } from '@/utils/processingData.js'

export function createPicDom(list, key, addToken = false) {
  if (!Array.isArray(list)) return ''
  const createBody = (src) => {
    return `<div style="padding-bottom: 1px;"><img src="${addToken ? authentication(src) : src}" style="width: 100%;max-width: 750px;" /></div>`
  }
  return list
    .map((_) => {
      if (_ instanceof Object && _[key]) return createBody(_[key])
      else return _
    })
    .join('')
}
